package com.bbs.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class MyUtil {

    /**
     * 把日期类型转为字符串，如获取当前日期的字符串
     * MyUtil.formatDate(new Date())---new Date表示当前日期
     * @param date
     * @return
     */
    public static String formatDate(Date date){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sdf.format(date);
    }

    public static String createActivateCode(){
        return new Date().getTime() + UUID.randomUUID().toString().replace("-","");
    }

    public static void main(String[] args) {
        //System.out.println(createActivateCode().length());
        String date = formatDate(new Date());
        System.out.println(date);
    }
}
